package com.web.dao;

import com.github.pagehelper.Page;
import com.web.controller.web.WebSysLogController;
import com.web.entity.MskDetail;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * @author FDjavaone
 */
public interface MskDetailMapper {


    @Delete({
        "delete from t_msk_detail",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into t_msk_detail (a_id, type,",
        " trade_id, transaction_price, ",
        " transaction_num, content, ",
        " detail,bal,name,phone, create_time, ",
        " modify_time)",
        " values (#{aId,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, ",
        " #{tradeId,jdbcType=BIGINT}, #{transactionPrice,jdbcType=DECIMAL}, ",
        " #{transactionNum,jdbcType=DECIMAL}, #{content,jdbcType=VARCHAR}, ",
        " #{detail,jdbcType=VARCHAR},#{bal,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},#{phone,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        " #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(MskDetail record);

    @InsertProvider(type=MskDetailSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(MskDetail record);



    @Select({
        "select",
        " id, a_id, type, trade_id, transaction_price, transaction_num, content, detail,bal,name,phone, ",
        " create_time, modify_time",
        " from t_msk_detail",
        " where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="a_id", property="aId", jdbcType=JdbcType.BIGINT),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="trade_id", property="tradeId", jdbcType=JdbcType.BIGINT),
        @Result(column="transaction_price", property="transactionPrice", jdbcType=JdbcType.DECIMAL),
        @Result(column="transaction_num", property="transactionNum", jdbcType=JdbcType.DECIMAL),
        @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
        @Result(column="detail", property="detail", jdbcType=JdbcType.VARCHAR),
        @Result(column="bal", property="bal", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    MskDetail selectByPrimaryKey(Long id);


    @UpdateProvider(type=MskDetailSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(MskDetail record);

    @Update({
        "update t_msk_detail",
        " set a_id = #{aId,jdbcType=BIGINT},",
          " type = #{type,jdbcType=INTEGER},",
          " trade_id = #{tradeId,jdbcType=BIGINT},",
          " transaction_price = #{transactionPrice,jdbcType=DECIMAL},",
          " transaction_num = #{transactionNum,jdbcType=DECIMAL},",
          " content = #{content,jdbcType=VARCHAR},",
          " detail = #{detail,jdbcType=VARCHAR},",
          " bal = #{bal,jdbcType=VARCHAR},",
          " name = #{name,jdbcType=VARCHAR},",
          " phone = #{phone,jdbcType=VARCHAR},",
          " create_time = #{createTime,jdbcType=TIMESTAMP},",
          " modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(MskDetail record);

    @Select({
            "select",
            " id, a_id, type, trade_id, transaction_price, transaction_num, content, detail,bal,name,phone, ",
            " create_time, modify_time",
            " from t_msk_detail",
            " where a_id = #{id,jdbcType=BIGINT}  order by create_time desc"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="a_id", property="aId", jdbcType=JdbcType.BIGINT),
            @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
            @Result(column="trade_id", property="tradeId", jdbcType=JdbcType.BIGINT),
            @Result(column="transaction_price", property="transactionPrice", jdbcType=JdbcType.DECIMAL),
            @Result(column="transaction_num", property="transactionNum", jdbcType=JdbcType.DECIMAL),
            @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
            @Result(column="detail", property="detail", jdbcType=JdbcType.VARCHAR),
            @Result(column="bal", property="bal", jdbcType=JdbcType.VARCHAR),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<MskDetail> selectByAid(Long id);

    @SelectProvider(type = MskDetailSqlProvider.class, method = "selectAllMsLogs")
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="a_id", property="aId", jdbcType=JdbcType.BIGINT),
            @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
            @Result(column="trade_id", property="tradeId", jdbcType=JdbcType.BIGINT),
            @Result(column="transaction_price", property="transactionPrice", jdbcType=JdbcType.DECIMAL),
            @Result(column="transaction_num", property="transactionNum", jdbcType=JdbcType.DECIMAL),
            @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
            @Result(column="detail", property="detail", jdbcType=JdbcType.VARCHAR),
            @Result(column="bal", property="bal", jdbcType=JdbcType.VARCHAR),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    Page<MskDetail> selectAllMsLogs(WebSysLogController.DetailsColumns detailsColumns);
}